** Figure A2
clear all
set more off 
capture log close
 
* main path to data
global path "~/Dropbox/Paraguay/1_data/7_replication_dataverse"
capture cd "$path"	

*figures= analysis figures
global figures "$path/figures"

* main panel
use "$path/data/main.dta", clear

xtset id year
generate autocracy = (year<1989)


// Generate indicator variables for years 1954 to 2007
forval year = 1954/2007 {
    generate y`year' = (year == `year')
}

// Generate the alt_1989 variable and set it to 0
generate alt_1989 = 0

** Figure A2.a

set scheme s1mono


set more off
reghdfe tmh_ha_log zdegree ///	
			y1954#c.zdegree y1955#c.zdegree ///
			y1956#c.zdegree y1957#c.zdegree y1958#c.zdegree y1959#c.zdegree y1960#c.zdegree ///
			y1961#c.zdegree y1962#c.zdegree y1963#c.zdegree y1964#c.zdegree y1965#c.zdegree ///
			y1966#c.zdegree y1967#c.zdegree y1968#c.zdegree y1969#c.zdegree y1970#c.zdegree ///
			y1971#c.zdegree y1972#c.zdegree y1973#c.zdegree y1974#c.zdegree y1975#c.zdegree ///
			y1976#c.zdegree y1977#c.zdegree y1978#c.zdegree y1979#c.zdegree y1980#c.zdegree ///
			y1981#c.zdegree y1982#c.zdegree y1983#c.zdegree y1984#c.zdegree y1985#c.zdegree ///
			y1986#c.zdegree y1987#c.zdegree y1988#c.zdegree ///
			alt_1989 ///
			y1990#c.zdegree y1991#c.zdegree y1992#c.zdegree y1993#c.zdegree y1994#c.zdegree ///
			y1995#c.zdegree y1996#c.zdegree y1997#c.zdegree y1998#c.zdegree y1999#c.zdegree ///
			y2000#c.zdegree y2001#c.zdegree y2002#c.zdegree  y2003#c.zdegree y2004#c.zdegree ///
			y2003#c.zdegree y2004#c.zdegree y2005#c.zdegree y2006#c.zdegree y2007#c.zdegree ///
			[pweight=p_weights] if sample_weight == 1, absorb(year id) cluster(id) nocons

			
		  coefplot, vertical omitted drop( zdegree y1954-y1988 y1990-y2007 ///
		  1.y1954#c.zdegree 1.y1955#c.zdegree 1.y1956#c.zdegree 1.y1957#c.zdegree ///
		  1.y1958#c.zdegree 1.y1959#c.zdegree 1.y1960#c.zdegree 1.y1961#c.zdegree ///
		  1.y1962#c.zdegree 1.y1963#c.zdegree 1.y1964#c.zdegree 1.y1965#c.zdegree ///
		  1.y1966#c.zdegree 1.y1967#c.zdegree 1.y1968#c.zdegree 1.y1969#c.zdegree ///
		  1.y1970#c.zdegree) ///
          yline(0, lcolor(red)) ///
          xlabel(1 "1971" 4 "1974" 7 "1977" 10 "1980" 13 "1983" 16 "1986" 19 "1989" 22 "1992" ///
		  25 "1995" 28 "1998" 31 "2001" 34 "2004" 37 "2007", angle(45)) ///
          xtitle("Year", size(3.7) margin(small))  ///
          ytitle("Effect relative to 1989", size(3.7) margin(small))  ///   
          ciopts(recast(rcap)) ///
          yscale(range(-0.067 0.165)) ///
          xline(19, lpattern(dash))
		   
graph export "$figures/figureA2a.pdf", replace


** Figure A2.b


set more off
reghdfe tmh_e zdegree ///
			y1954#c.zdegree y1955#c.zdegree ///
			y1956#c.zdegree y1957#c.zdegree y1958#c.zdegree y1959#c.zdegree y1960#c.zdegree ///
			y1961#c.zdegree y1962#c.zdegree y1963#c.zdegree y1964#c.zdegree y1965#c.zdegree ///
			y1966#c.zdegree y1967#c.zdegree y1968#c.zdegree y1969#c.zdegree y1970#c.zdegree ///
			y1971#c.zdegree y1972#c.zdegree y1973#c.zdegree y1974#c.zdegree y1975#c.zdegree ///
			y1976#c.zdegree y1977#c.zdegree y1978#c.zdegree y1979#c.zdegree y1980#c.zdegree ///
			y1981#c.zdegree y1982#c.zdegree y1983#c.zdegree y1984#c.zdegree y1985#c.zdegree ///
			y1986#c.zdegree y1987#c.zdegree y1988#c.zdegree ///
			alt_1989 ///
			y1990#c.zdegree y1991#c.zdegree y1992#c.zdegree y1993#c.zdegree y1994#c.zdegree ///
			y1995#c.zdegree y1996#c.zdegree y1997#c.zdegree y1998#c.zdegree y1999#c.zdegree ///
			y2000#c.zdegree y2001#c.zdegree y2002#c.zdegree  y2003#c.zdegree y2004#c.zdegree ///
			y2003#c.zdegree y2004#c.zdegree y2005#c.zdegree y2006#c.zdegree y2007#c.zdegree ///
			y1982#c.zdegree  y1983#c.zdegre y1984#c.zdegree y1985#c.zdegree y1986#c.zdegree ///
			y1987#c.zdegree y1988#c.zdegree alt_1989  y1990#c.zdegree ///
			[pweight=p_weights] if sample_weight == 1, absorb(year id) cluster(id) nocons

coefplot, vertical omitted drop( zdegree y1954-y1988 y1990-y2007 ///
		  1.y1954#c.zdegree 1.y1955#c.zdegree 1.y1956#c.zdegree 1.y1957#c.zdegree ///
		  1.y1958#c.zdegree 1.y1959#c.zdegree 1.y1960#c.zdegree 1.y1961#c.zdegree ///
		  1.y1962#c.zdegree 1.y1963#c.zdegree 1.y1964#c.zdegree 1.y1965#c.zdegree ///
		  1.y1966#c.zdegree 1.y1967#c.zdegree 1.y1968#c.zdegree 1.y1969#c.zdegree ///
		  1.y1970#c.zdegree) ///
          yline(0, lcolor(red)) ///
           xlabel(1 "1971" 4 "1974" 7 "1977" 10 "1980" 13 "1983" 16 "1986" 19 "1989" 22 "1992" ///
		  25 "1995" 28 "1998" 31 "2001" 34 "2004" 37 "2007", angle(45)) ///
          xtitle("Year", size(3.7) margin(small))  ///
          ytitle("Effect relative to 1989", size(3.7) margin(small))  ///   
          ciopts(recast(rcap)) ///
          yscale(range(-0.006 0.022)) ///
          xline(19, lpattern(dash))			
			
graph export "$figures/figureA2b.pdf", replace


** Figure A2.c


set more off
	reghdfe tmh_ha_log zbetweenness ///
			y1954#c.zbetweenness y1955#c.zbetweenness y1956#c.zbetweenness ///
			y1957#c.zbetweenness y1958#c.zbetweenness y1959#c.zbetweenness y1960#c.zbetweenness ///
			y1961#c.zbetweenness y1962#c.zbetweenness y1963#c.zbetweenness y1964#c.zbetweenness ///
			y1965#c.zbetweenness y1966#c.zbetweenness y1967#c.zbetweenness y1968#c.zbetweenness ///
			y1969#c.zbetweenness y1970#c.zbetweenness y1971#c.zbetweenness y1972#c.zbetweenness ///
			y1973#c.zbetweenness y1974#c.zbetweenness y1975#c.zbetweenness y1976#c.zbetweenness ///
			y1977#c.zbetweenness y1978#c.zbetweenness y1979#c.zbetweenness y1980#c.zbetweenness ///
			y1981#c.zbetweenness y1982#c.zbetweenness y1983#c.zbetweenness y1984#c.zbetweenness ///
			y1985#c.zbetweenness y1986#c.zbetweenness y1987#c.zbetweenness y1988#c.zbetweenness ///
			alt_1989    ///
			y1990#c.zbetweenness y1991#c.zbetweenness y1992#c.zbetweenness y1993#c.zbetweenness ///
			y1994#c.zbetweenness y1995#c.zbetweenness  y1996#c.zbetweenness y1997#c.zbetweenness ///
			y1998#c.zbetweenness y1999#c.zbetweenness  y2000#c.zbetweenness y2001#c.zbetweenness ///
			y2002#c.zbetweenness y2003#c.zbetweenness  y2004#c.zbetweenness y2005#c.zbetweenness ///
			y2006#c.zbetweenness y2007#c.zbetweenness  ///
			zbetweenness [pweight=p_weights] if sample_weight == 1, absorb(year id) cluster(id) nocons



coefplot, vertical omitted drop(zbetweenness y1954-y1988 y1990-y2007 ///
		  1.y1954#c.zbetweenness 1.y1955#c.zbetweenness 1.y1956#c.zbetweenness 1.y1957#c.zbetweenness ///
		  1.y1958#c.zbetweenness 1.y1959#c.zbetweenness 1.y1960#c.zbetweenness 1.y1961#c.zbetweenness ///
		  1.y1962#c.zbetweenness 1.y1963#c.zbetweenness 1.y1964#c.zbetweenness 1.y1965#c.zbetweenness ///
		  1.y1966#c.zbetweenness 1.y1967#c.zbetweenness 1.y1967#c.zbetweenness 1.y1968#c.zbetweenness ///
		  1.y1969#c.zbetweenness 1.y1970#c.zbetweenness) ///
          yline(0, lcolor(red)) ///
          xlabel(1 "1971" 4 "1974" 7 "1977" 10 "1980" 13 "1983" 16 "1986" 19 "1989" 22 "1992" ///
		  25 "1995" 28 "1998" 31 "2001" 34 "2004" 37 "2007", angle(45)) ///
          xtitle("Year", size(3.7) margin(small))  ///
          ytitle("Effect relative to 1989", size(3.7) margin(small))  ///   
          ciopts(recast(rcap)) ///
          yscale(range(-0.033 0.092)) ///
          xline(19, lpattern(dash))
		  
graph export "$figures/figureA2c.pdf", replace

** Figure A2.d


set more off
reghdfe tmh_e zbetweenness ///
			 y1954#c.zbetweenness y1955#c.zbetweenness y1956#c.zbetweenness ///
			y1957#c.zbetweenness y1958#c.zbetweenness y1959#c.zbetweenness y1960#c.zbetweenness ///
			y1961#c.zbetweenness y1962#c.zbetweenness y1963#c.zbetweenness y1964#c.zbetweenness ///
			y1965#c.zbetweenness y1966#c.zbetweenness y1967#c.zbetweenness y1968#c.zbetweenness ///
			y1969#c.zbetweenness y1970#c.zbetweenness y1971#c.zbetweenness y1972#c.zbetweenness ///
			y1973#c.zbetweenness y1974#c.zbetweenness y1975#c.zbetweenness y1976#c.zbetweenness ///
			y1977#c.zbetweenness y1978#c.zbetweenness y1979#c.zbetweenness y1980#c.zbetweenness ///
			y1981#c.zbetweenness y1982#c.zbetweenness y1983#c.zbetweenness y1984#c.zbetweenness ///
			y1985#c.zbetweenness y1986#c.zbetweenness y1987#c.zbetweenness y1988#c.zbetweenness ///
			alt_1989    ///
			y1990#c.zbetweenness  y1991#c.zbetweenness y1992#c.zbetweenness y1993#c.zbetweenness ///
			y1994#c.zbetweenness y1995#c.zbetweenness  y1996#c.zbetweenness y1997#c.zbetweenness ///
			y1998#c.zbetweenness y1999#c.zbetweenness  y2000#c.zbetweenness y2001#c.zbetweenness ///
			y2002#c.zbetweenness y2003#c.zbetweenness  y2004#c.zbetweenness y2005#c.zbetweenness ///
			y2006#c.zbetweenness y2007#c.zbetweenness  ///
			zbetweenness  [pweight=p_weights] if sample_weight == 1, ///
			absorb(year id) cluster(id) nocons


coefplot, vertical omitted drop(zbetweenness y1954-y1988 y1990-y2007 ///
		  1.y1954#c.zbetweenness 1.y1955#c.zbetweenness 1.y1956#c.zbetweenness 1.y1957#c.zbetweenness ///
		  1.y1958#c.zbetweenness 1.y1959#c.zbetweenness 1.y1960#c.zbetweenness 1.y1961#c.zbetweenness ///
		  1.y1962#c.zbetweenness 1.y1963#c.zbetweenness 1.y1964#c.zbetweenness 1.y1965#c.zbetweenness ///
		  1.y1966#c.zbetweenness 1.y1967#c.zbetweenness 1.y1967#c.zbetweenness 1.y1968#c.zbetweenness ///
		  1.y1969#c.zbetweenness 1.y1970#c.zbetweenness) ///
          yline(0, lcolor(red)) ///
          xlabel(1 "1971" 4 "1974" 7 "1977" 10 "1980" 13 "1983" 16 "1986" 19 "1989" 22 "1992" ///
		  25 "1995" 28 "1998" 31 "2001" 34 "2004" 37 "2007", angle(45)) ///
          xtitle("Year", size(3.7) margin(small))  ///
          ytitle("Effect relative to 1989", size(3.7) margin(small))  ///   
          ciopts(recast(rcap)) ///
          yscale(range(-0.006 0.018)) ///
          xline(19, lpattern(dash))
		  
graph export "$figures/figureA2d.pdf", replace



